Ext.define('DragonApp.view.user.Grid', {
    extend: 'DragonApp.view.foundation.Grid',

    alias: ['widget.systemuser'],

    requires: [
        'DragonApp.store.JsonPUser',
        'DragonApp.view.user.Controller'
    ],

    title: '系统账号',

    height: 600,

    controller: 'user',

    columns: [
        { text: '序号', xtype: 'rownumberer', width: 80, align: 'center' },
        { text: 'ID', dataIndex: 'id', align: 'center', width: 100, hidden: true, hideable: false },
        { text: '账号', dataIndex: 'user', align: 'center', width: 100 },
        { text: '姓名', dataIndex: 'cname', align: 'center', width: 100 },
        { text: '角色', dataIndex: 'role_name', align: 'center', width: 100 },
        { text: '密码', dataIndex: 'pass', itemId: 'pass', hideable: false, hidden: true, align: 'center', width: 100 },
        { text: '状态', dataIndex: 'status', renderer: 'statusRender', align: 'center', width: 100 },
        { text: '创建时间', dataIndex: 'create_time', align: 'center', width: 144 },
        { text: '更新时间', dataIndex: 'update_time', align: 'center', width: 144 },
        { text: '备注', dataIndex: 'comments', flex: 1 }
    ],
    store: {
        type: 'jsonPUserStore',
        storeId : 'jsonPUserStore'
    },

    selModel: {
        selType: 'checkboxmodel'
    },

    initComponent: function() {
        var me = this;
        me.tbar = [
            {
                xtype: 'button',
                text: '新建用户',
                itemId: 'new',
                tooltip: 'New',
                handler: 'onAdd',
                glyph: 'xf234@FontAwesome',
                width: 100
            }, {
                xtype: 'button',
                text: '批量删除',
                itemId: 'batdelete',
                tooltip: '批量删除',
                handler: 'onBatDelete',
                glyph: 'xf014@FontAwesome',
                width: 100
            },'->', {
                xtype: 'textfield',
                name: 'searchfield',
                itemId: 'search_field',
                emptyText: '请输入筛选关键字',
                listeners: {
                    specialKey: 'onTextFieldSpecialKeySearch'
                }
            }, {
                xtype: 'button',
                itemId: 'search_btn',
                text: '搜索',
                reference: 'search',
                iconCls: 'fa fa-search fa-lg buttonIcon',
                listeners: {
                    click: 'onSearch'
                }
            }/*'->',{
                xtype: 'button',
                text: '刷新列表',
                tooltip: 'Refresh',
                handler: 'onRefresh',
                glyph: 'xf021@FontAwesome',
                width: 100
            }*/
        ];
        me.callParent(arguments);
        //========
        //权限控制
        //========
        if ('系统用户' == sessionStorage.getItem("DragonApp_role_name")) {
            me.queryById('new').hide();
            me.queryById('edit').hide();
            me.queryById('delete').hide();
        }
    }
});